﻿using DLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        BLLShort bl = new BLLShort();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Info();
            }
        }
        //Load查询
        public void Info()
        {

            //获取手机号
            BasePage page = new BasePage();
            //string us = page.LoginUser.ToString();
            string us = "13358365701";
            string ID = "13558365701";
            //长途拼车申请记录
            ApplyInfo(us);
            ApplyInfo2(us);
            ApplyInfo3(us);
            ApplyInfo4(us);
            //
            ReleInfo(us);
            ReleInfo2(us);
            //
            ApplyShort(ID);
            //
            ApplyData(ID);
            ApplyData2(ID);


        }
       
        //查询长途发布的拼车记录
        private void ReleInfo(string id)
        {
            string al = "";
            //数据查询
            DataTable dt = BLLShort.DataSelect(id, al);
            ReleGridView.DataSource = dt;
            ReleGridView.DataBind();
        }
        //查询长途发布的拼车历史记录
        private void ReleInfo2(string id)
        {
            string al = "已过期";
            //数据查询
            DataTable dt = BLLShort.DataSelect2(id, al);
            ReleGridView2.DataSource = dt;
            ReleGridView2.DataBind();
        }



        //查询长途拼车申请记录
        public void ApplyInfo(string id)
        {
            var dt = bl.DataLong(id);
            LongGridView.DataSource = dt;
            LongGridView.DataBind();
        }
        //查询已加入长途申请的信息
        private void ApplyInfo2(string LongID)
        {
            string Statem = " al.ALStatus='已同意'";
            DataTable dt = bl.ApplyInfo(LongID, Statem);
            LongGridView2.DataSource = dt;
            LongGridView2.DataBind();
        }
        //查询未加入长途申请的信息
        private void ApplyInfo3(string LongID)
        {
            string Statem = " al.ALStatus='待受理'";
            DataTable dt = bl.ApplyInfo(LongID, Statem);
            LongGridView3.DataSource = dt;
            LongGridView3.DataBind();
        }
        //查询被退回长途申请的信息
        private void ApplyInfo4(string LongID)
        {
            string Statem = " al.ALStatus='未同意'";
            DataTable dt = bl.ApplyInfo(LongID, Statem);
            LongGridView4.DataSource = dt;
            LongGridView4.DataBind();
        }



        //上下班发布拼车信息查询
        private void ApplyShort(string ID)
        {
            string States = "";
            DataTable dt = bl.ApplyShort(ID, States);
            GvShort.DataSource = dt;
            GvShort.DataBind();
        }
        //上下班发布的历史拼车信息查询
        private void ApplyShort2(string ID)
        {
            string States = "";
            DataTable dt = bl.ApplyShort(ID, States);
            GvShort2.DataSource = dt;
            GvShort2.DataBind();
        }


        //上下班申请拼车信息查询
        private void ApplyData(string ID)
        {
            string States = "";
            DataTable dt = bl.ApplyData(ID, States);
            GvApply.DataSource = dt;
            GvApply.DataBind();
        }

        //上下班申请拼车信息查询已同意
        private void ApplyData2(string ID)
        {
            string States = " and ae.ASStatus='已同意'";
            DataTable dt = bl.ApplyData(ID, States);
            GvApply2.DataSource = dt;
            GvApply2.DataBind();
        }

        //上下班申请拼车信息查询待受理
        private void ApplyData3(string ID)
        {
            string States = " and ae.ASStatus=' and SStatus='待受理''";
            DataTable dt = bl.ApplyData(ID, States);
            GvApply3.DataSource = dt;
            GvApply3.DataBind();
        }

        //上下班申请拼车信息查询未同意
        private void ApplyData4(string ID)
        {
            string States = " and ae.ASStatus=' and SStatus='未同意''";
            DataTable dt = bl.ApplyData(ID, States);
            GvApply4.DataSource = dt;
            GvApply4.DataBind();
        }
        protected void ReleGridView_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void ReleGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToLower()=="see")
            {
                //获取编号ID
                string LongID = e.CommandArgument.ToString();
                Response.Redirect($"CarpoolingRecord-Son1.aspx?id={LongID}");
            }
        }
        protected void GvShort_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.ToLower() == "see")
            {
                //获取编号ID
                string LongID = e.CommandArgument.ToString();
                Response.Redirect($"CarpoolingRecord-Son2.aspx?id={LongID}");
            }
        }
        protected void GvShort_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        {

        }
    }
}